    
// <productMethods ref="productMethods"/>
// <packageProduct ref="packageProduct"/>

import { mapMutations,mapState } from "vuex";
export default{
    data(){

    },
    computed: {
        ...mapState({
            shoppingList(state) {return state.cartModule.shoppingList},
        }),
    },
    methods:{
        /**
         * @description 增加/减少商品
         */
         ...mapMutations(["increasePro", "decreasePro", "setMultipleVisible"]),
        /**
       * @description 打开弹窗
       */
        openPop(refName, params) {
            this.$store.commit("setMultipleVisible", {
                list: ["cartVisible"],
                show: true,
            });
            this.$refs[refName].showPopup(params);
        },
        decrease(item) {
            //if (this.cando() == false) return;
            this.decreasePro({ item });
        },
        async increase(item) {
            //if (this.cando() == false) return;
            let { type } = item;
            let defaultParams = {
                item,
                needReq: true,
            };
            if (type == 3) {
                this.openPop("packageProduct", {
                    ...defaultParams,
                    cb: this.packageModalCallBack,
                });
            } else if (type == 5) {
                this.openPop("productMethods", {
                    ...defaultParams,
                    cb: this.methodModalCallBack,
                    popType: 1,
                });
            } else {
                let copyItem = item?.isWeightingSale == true ? { ...item } : item;
                this.increasePro({ item: copyItem });
            }
        },
        /**
         * @description 套餐弹窗回调
         */
         packageModalCallBack(params) {
            let { mapItem } = params;
            this.increasePro({ item: mapItem });
        },
        /**
         * @description 菜品做法弹窗回调
         */
        methodModalCallBack(params) {
            let { mapItem } = params;
            this.increasePro({ item: mapItem });
        },
    }
}